<!--社区列表-->
<template>
    <div>
        <el-card class="box-card" shadow="never">
          <el-breadcrumb separator-class="el-icon-arrow-right">
              <el-breadcrumb-item>社区管理</el-breadcrumb-item>
              <el-breadcrumb-item>随手拍列表</el-breadcrumb-item>
          </el-breadcrumb>
            <div class="yx_line"></div>
            <el-row :gutter="10" style="margin-top:20px;">
            </el-col>
                   <el-col :span='6'>
                      <el-input v-model="user_id">
                        <template slot="prepend">用户id号</template>
                      </el-input>
                   </el-col>
                   <el-col :span='6'>
                      <el-input  v-model="realname">
                        <template slot="prepend">姓名</template>
                      </el-input>
                   </el-col>
                </el-row>
            <el-row class="yx_el_row">
                <el-col>
                    <el-button type="success" plain @click="search">筛选</el-button>
                </el-col>
            </el-row>
            <el-table class="yx_table" border :data="randompicturelist">
                <el-table-column prop="index" label="序号" width="100">
                </el-table-column>
                <el-table-column prop="title" label="标题" width="180">
                </el-table-column>
                <el-table-column prop="user_id" label="用户id号" width="100">
                </el-table-column>
                <el-table-column prop="if_realname" label="是否实名" width="100">
                </el-table-column>
                <el-table-column prop="realname" label="姓名" width="100">
                </el-table-column>
                <el-table-column prop="contact_tel" label="联系电话" width="100">
                </el-table-column>
                <el-table-column prop="if_connected" label="是否与当事人沟通" width="100">
                </el-table-column>
                <el-table-column prop="created_time" label="提交时间" width="120">
                </el-table-column>
                <el-table-column prop="status" label="状态" width="120">
                </el-table-column>
                <el-table-column  label="操作">
                    <template slot-scope="scope">
                        <el-tooltip class="item" effect="dark" content="标记已处理" placement="bottom-start">
                            <el-button type="primary" icon="el-icon-check" @click="handle(scope.row.id)" :disabled="scope.row.status_code==1" circle></el-button>
                        </el-tooltip>
                        <el-tooltip class="item" effect="dark" content="查看" placement="bottom-start">
                            <el-button type="info" icon="el-icon-notebook-1" @click="edit(scope.row.id,0)" circle></el-button>
                        </el-tooltip>
                        <el-tooltip class="item" effect="dark" content="删除" placement="bottom-start">
                            <el-button type="warning" icon="el-icon-delete" @click="del(scope.row.id)" circle></el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
            </el-table>
            <Pagination :total_count="total_count" :getList="getList"></Pagination>
        </el-card>
    </div>
</template>

<script>
    import Pagination from '@/components/Pagination.vue';
    import { getRandomPictureList,delRandomPicture,handleRandomPictureStatus } from '@/api/randompicture.js';
    export default {
        name: 'RandomPictureList',
        inject:['reload'],
        components:{ Pagination },
        data() {
            return {
                randompicturelist:[],
                total_count:0,
                user_id:'',
                realname:''
            }
        },
        methods: {
            getList(current_page,page_size){
                var send_data={
                    api_token:this.$store.getters.getSessionId,
                    current_page:current_page,
                    page_size:page_size,
                    user_id:this.user_id,
                    realname:this.realname
                }
                let that=this;
                getRandomPictureList(send_data).then(function(response){
                   if(response.data.code==1){
                     that.randompicturelist=response.data.list;
                     that.total_count=response.data.total_count;
                   }
                })
            },
            search(){
               this.getList(1,this.$store.state.default_page_size);
            },
            edit(id,edit_type){
                this.$router.push({
                    name:'randompicturedetail',
                    params:{id:id,edit_type:edit_type}
                });
            },
            handle(id){
               let that=this;
               this.$confirm('确认标记为已处理, 是否继续?', '提示', {
                   confirmButtonText: '确定',
                   cancelButtonText: '取消',
                   type: 'warning'
               }).then((e) => {
                   var send_data={
                       api_token : that.$store.getters.getSessionId,
                       id:id,
                       status:1
                   };
                   handleRandomPictureStatus(send_data).then(function(response){
                      let type=response.data.code==1?'success':'error';
                      let msg=response.data.code==1?'标记成功':'标记失败'
                      that.$message({
                          message:msg,
                          type:type,
                          duration:1000,
                          onClose:function(e){
                              that.reload();
                          }
                      });
                   })
               })
            },
            del(id){
                let that=this;
                //弹框提示
                this.$confirm('确认删除, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then((e) => {
                    var send_data={
                        api_token : that.$store.getters.getSessionId,
                        id:id
                    };
                    delRandomPicture(send_data).then(function(response){
                        let type=response.data.code==1?'success':'error';
                        let msg=response.data.code==1?'删除成功':'删除失败'
                        that.$message({
                            message:msg,
                            duration:1200,
                            type:type,
                            onClose:function(e){
                                that.reload();
                            }
                        });
                    })
                })
            },
        },
        created() {
             this.getList(1,this.$store.state.default_page_size);
        }
    }
</script>

<style>
     @import url('../../assets/css/table.css');
</style>
